<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta content="yes" name="apple-mobile-web-app-capable">
  <meta content="yes" name="apple-touch-fullscreen">
  <meta content="telephone=no,email=no" name="format-detection">
  <script src="./flex.js"></script>
  <title>接单王活动</title>
  <link rel="stylesheet" href="./index.css">
</head>
<body>
  <p class="active-time">活动时间: 2020年3月16日 18:00:00-3月23日 18:00:00</p>
  <div class="title-0"></div>
  <p class="rule-desc">1.活动期间，根据陪玩大神的所有技能成功接单进行排名,<span class="uu">一经发现作弊,刷单行为,取消活动参与资格,且根据平台相关规定予以惩罚!</span></p>
  <p class="rule-desc">2.活动截止时，接单总数榜第一名可获得</p>
  <div class="rule-desc-gift">
    <div class="rule-desc-gift-0">
      <div class="rule-desc-gift-img">
        <img src="./images/prize0.png" width="100%" height="100%" alt="">
      </div>
      <p class="rule-desc-gift-text">接单王勋章(7天)</p>
    </div>
    <div class="rule-desc-gift-1">
      <div class="rule-desc-gift-img">
        <img src="./images/prize1.png" width="100%" height="100%" alt="">
      </div>
      <p class="rule-desc-gift-text">首页推荐系数扶持(7天)</p>
    </div>
  </div>
  <p class="rule-desc">3.活动截至时，接单总数榜前30名用户，且总接单量达56单,即可享受官方钻石奖励</p>
  <div class="rule-desc-3">
    <p>用户个人总接单收益的<span class="uu uuu">5%钻石</span></p>
  </div>
  <div class="clearfix"></div>
  <div class="title-1"></div>
  <table>
    <thead>
      <tr>
        <td width="20%">名次</td>
        <td width="30%">头像</td>
        <td width="30%">昵称ID</td>
        <td width="20%">接单总数</td>
      </tr>
    </thead>
    <tbody>
     
    </tbody>
  </table>
  <div class="total-footer">
  </div>
  <p class="desc">本活动解释权归声撩官方所有</p>
</body>
<script src="./lib.js"></script>
<script>
let lists = [];
let userInfo = [];
// const baseUrl = "http://lyj.ztaudio-activity.com";
// const baseUrl = "http://47.103.212.118:5084";
const baseUrl = 'http://ztaudio-activity.kekestar.cn';


var $_GET = (function(){
        var url = window.document.location.href.toString();
        var u = url.split("?");
        if(typeof(u[1]) == "string"){
            u = u[1].split("&");
            var get = {};
            for(var i in u){
                var j = u[i].split("=");
                get[j[0]] = j[1];
            }
            return get;
        } else {
            return {};
        }
    })();

  getBeforeThirty();
  getUserInfo();

  function getBeforeThirty() {
    ajaxGet(baseUrl + "/order_king/before_thirty", {}, function(req) {
      if(req.code == 200) {
        lists = req.data
        if(lists.length > 0 ) {          
          let obj = document.getElementsByClassName('total-item-box')[0];

          for(let i=0; i<lists.length;i++) {
            let trElem = document.createElement('tr');
            let tdElem = document.createElement('td');
            tdElem.setAttribute('width', '20%');
             if(i == 0) {
              let numberObj = document.createElement('div');
              numberObj.setAttribute('class','number-0');
              tdElem.appendChild(numberObj);
            } else if(i == 1) {
              let numberObj = document.createElement('div');
              numberObj.setAttribute('class','number-1');
              tdElem.appendChild(numberObj);
            } else if(i == 2) {
              let numberObj = document.createElement('div');
              numberObj.setAttribute('class','number-2');
              tdElem.appendChild(numberObj);
            } else {
              tdElem.textContent = i + 1;
            }
            trElem.appendChild(tdElem);

            tdElem = document.createElement('td');
            tdElem.setAttribute('width', '30%');
             let imgBox = document.createElement('div');
            imgBox.setAttribute('class','head-img');
            let img = document.createElement('img');
            img.setAttribute('src', lists[i].portrait);
            img.setAttribute('width', '100%');
            img.setAttribute('height', '100%');
            imgBox.appendChild(img);
            tdElem.appendChild(imgBox);
            trElem.appendChild(tdElem);


            tdElem = document.createElement('td');
            tdElem.setAttribute('width', '30%');
            let nicknameP = document.createElement('p');
            nicknameP.textContent = lists[i].nickname;
            tdElem.appendChild(nicknameP);
            let uuidP = document.createElement('p');
            uuidP.textContent = "ID:" + lists[i].uuid;
            tdElem.appendChild(uuidP);
            trElem.appendChild(tdElem);

            tdElem = document.createElement('td');
            tdElem.setAttribute('width', '20%');
            tdElem.textContent = lists[i].total_number;
            trElem.appendChild(tdElem);

            document.getElementsByTagName('tbody')[0].appendChild(trElem);
            
          }
          document.getElementsByTagName('table')[0].style.display = 'block';
        } else {
          
        }
      } 
    }, function(err) {
      console.log(err)
    });
  }

  function getUserInfo() {
    ajaxGet(baseUrl + "/order_king/user_info/"+ $_GET['user_id'], {}, function(req) {
      if(req.code == 200) {
        userInfo = req.data

        
        let outerObj = document.getElementsByClassName('total-footer')[0];

        // 头像
        let headImgOuterElem = document.createElement('div');
        let headImgInnerElem = document.createElement('div');
        headImgInnerElem.setAttribute('class', 'head-footer-img');
        let imgElem = document.createElement('img');
        imgElem.setAttribute('src', userInfo[0].portrait);
        imgElem.setAttribute('width', '100%');
        imgElem.setAttribute('height', '100%');
        headImgInnerElem.appendChild(imgElem);
        headImgOuterElem.appendChild(headImgInnerElem);
        outerObj.appendChild(headImgOuterElem);

        // 昵称ID
        let nicknameOuterElem = document.createElement('div');
        let nicknamePElem = document.createElement('p');
        nicknamePElem.textContent = userInfo[0].nickname;
        nicknameOuterElem.appendChild(nicknamePElem);
        let uuidPElem = document.createElement('p');
        uuidPElem.textContent = "ID:" + userInfo[0].uuid;
        nicknameOuterElem.appendChild(uuidPElem);
        outerObj.appendChild(nicknameOuterElem);

        //接单数
        let numberOuterElem = document.createElement('div');
        numberOuterElem.setAttribute('class', 'number');
        numberOuterElem.textContent = userInfo[0].total_number; 
        outerObj.appendChild(numberOuterElem);
      }
    }, function(err) {
      console.log(err)
    });
  }
</script>
</html>